<?php
/**
 * Copyright (C) 2010-2013 Oscar Valenzuela B. (ovalenzuela@xpertians.com)
 * 
 * This file is part of WarpIT.
 * WarpIT is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * any later version.
 * 
 * WarpIT is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 * 
 * You should have received a copy of the GNU General Public License
 * along with WarpIT.  If not, see <http://www.gnu.org/licenses/>.
 */
/**
 * This class cointains Info Requests methods for WarpIT
 * @author Oscar Valenzuela <ovalenzuela@xpertians.com>
 * @version 1.0
 * @package WarpIT!
 * @copyright Copyright (C) 2010-2013 Xpertians SpA
 * @license GNU GPLv3 or later
 * @link http://www.xpertians.com
 */
 
Class Request{
	
	/**
	 * Config information
	 *
	 * @var mixed
	 */
	private $config;
	
	/**
	 * Results container
	 *
	 * @var mixed
	 */
	private $response;
	
	/**
	 * Request Get info from HSS and HLR provisioning
	 *
	 */
	function Request(){
		include_once("Vendors/HSS_Online/config.php");
		$this->config		= $config;
	}
		
	/**
	 * Request_MSISDN Get info from HSS and HLR provisioning
	 *
	 * Following syntax are recognized :
	 *
	 * @param string $MSISDN Phone number
	 * @return array
	 */
	function Request_MSISDN($MSISDN){
		/* clasification table */
		$requestType		= "hss";
		$requestHost		= "hss";
		
		switch($requestType){
			case "hss":
				$this->response		= $this->Request_info_hss($MSISDN);
			break;
		}
		
		return $this->response;
	}
	
	/**
	 * Request_info_hss Get info from HSS and parse the results
	 *
	 * Following syntax are recognized :
	 *
	 * @param string $MSISDN Phone number with country code
	 * @return array
	 */
	 function Request_info_hss($MSISDN){
		$req_hss	= new Request_HSS($this->config['baseUrl'], $this->config['userLogin'], $this->config['passLogin'], $this->config['proxyServer']);
		$req_hss->Request_LGI();
		$pHSS			= new Parse_HSS();
		$data			= array();
		
		$response		= $req_hss->Request_LST_SUB($MSISDN);
		$data['orig']['SUB']	= $response['body'];
		$res_sub		= $pHSS->Parse_SUB($response['body']);
		
		$response		= $req_hss->Request_LST_DYNSUB($MSISDN);
		$data['orig']['DYNSUB']	= $response['body'];
		$res_dynsub		= $pHSS->Parse_DYNSUB($response['body']);
		
		$response		= $req_hss->Request_LST_CFALL($MSISDN);
		$data['orig']['CFALL']	= $response['body'];
		$res_cfall		= $pHSS->Parse_CFALL($response['body']);
		
		$response		= $req_hss->Request_LST_ECATEGORY($MSISDN);
		$data['orig']['ECATEGORY']	= $response['body'];
		$res_ecategory		= $pHSS->Parse_ECATEGORY($response['body']);
		
		$response		= $req_hss->Request_LST_CWAIT($MSISDN);
		$data['orig']['CWAIT']	= $response['body'];
		$res_cwait		= $pHSS->Parse_CWAIT($response['body']);
		
		$response		= $req_hss->Request_LST_OPTGPRS($MSISDN);
		$data['orig']['OPTGPRS']	= $response['body'];
		$res_optgprs		= $pHSS->Parse_OPTGPRS($response['body']);
		
		$data['parsed']		= array_merge($res_sub, $res_dynsub, $res_cfall, $res_ecategory, $res_cwait, $res_optgprs);
		
		$tHSS			= new Translate_HSS();
		$res			= $tHSS->Translate($data['parsed']);
		$data['trans']		= $res;
		return $data;
	 }
}
?>
